<template>
<div class="content-center">
  <div class="content-cotainer border-box">
    <div class="content-breadcrumb">
      <el-breadcrumb separator="/" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/' }">审计作业</el-breadcrumb-item>
        <el-breadcrumb-item>审计取证单列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="audit-content">
      <div class="centent-title">
        <span>{{title}}</span>
      </div>
      <!-- 页面内容 -->
      <div class="centent-inner" style="padding:15px;">

        <el-row :gutter="20" style="margin-top: 20px;padding-left: 2px;">
          <el-form :model="form" label-width="130px" size="small">
            <el-row>
             <el-row>
              <el-col :span="7">
                <el-form-item label="审计取证单名称：">
                  <el-input v-model="form.auditEvdblNm" placeholder="请输入审计取证单名称"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="7">
                <el-form-item label="审计事项：">
                  <el-select v-model="form.auditItemDsc" placeholder="请选择审计事项" size="small">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
                <el-col :span="7">
                    <el-form-item label="细分审计事项：">
                        <el-select v-model="form.auditItemDsc" placeholder="请选择审计事项" size="small">
                            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
               </el-row>
               <el-row>
                <el-col :span="7">
                    <el-form-item label="取证单状态：">
                        <el-select v-model="form.lcsCd" placeholder="请选择取证单状态" size="small">
                            <el-option v-for="item in lcsCdOptions" :key="item.value" :label="item.label" :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="附件名称：">
                        <el-input v-model="form.docNm" placeholder="请输入附件名称"></el-input>
                    </el-form-item>
                </el-col>
              <el-col :span="7">
                <el-form-item label="编制人：">
                    <el-input v-model="form.rcrdCrtpsnNm" placeholder="请输入编制人"></el-input>
                </el-form-item>
              </el-col>
             </el-row>
             <el-row>
                <el-col :span="7">
                    <el-form-item label="审计事项摘要：">
                        <el-input v-model="form.auditorMatterDsc" placeholder="请输入审计事项摘要"></el-input>
                    </el-form-item>
                </el-col>

                <el-col :span="16">
                    <el-form-item label="编制日期：">
                        <!--<el-date-picker v-model="form.rcrdCrtTm" style="width: 160px" placeholder="请选择编制日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" size="small"></el-date-picker>&#45;&#45;<el-date-picker v-model="form.rcrdCrtTm" style="width: 160px" placeholder="请选择编制日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date" size="small"></el-date-picker>-->
                        <el-date-picker v-model="form.createDt"  type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
                        <el-button type="primary" icon="el-icon-search" size="small" style="margin-left:33px;" @click="findByParam()">查询</el-button>
                        <el-button type="primary" icon="el-icon-refresh-left" size="small" style="margin-left:33px;" @click="reset()">重置</el-button>
                    </el-form-item>
                </el-col>
              </el-row>
            </el-row>
          </el-form>
        </el-row>

          <el-row justify="space-around" type="flex">
              <el-col :span="24">
                  <el-button type="primary" icon="el-icon-document" size="small" @click="flushCom">新建</el-button>
                  <el-button type="primary" icon="el-icon-s-custom" size="small">共享</el-button>
                  <!-- <el-button type="success" icon="el-icon-message" size="small" style="float:right" @click="updateById(sels)">修改</el-button> -->
                  <el-button type="danger" icon="el-icon-delete" size="small"  @click="deleteById(sels)">废弃</el-button>
              </el-col>
          </el-row>
        <el-row>
          <el-table :data="datalist" stripe @selection-change="selsChange" style="width: 100%;">
            <el-table-column fixed type="selection" width="50" ></el-table-column>
            <el-table-column type="index" label="序号" width="50" align="center" ></el-table-column>
            <el-table-column label="审计取证单名称" prop="auditEvdblNm" align="center" width="200px">
              <template slot-scope="scope">
                <el-button type="text" @click="updateById(scope.row.auditEvdblId)" >{{scope.row.auditEvdblNm}}</el-button>
              </template>
            </el-table-column>
            <el-table-column label="审计事项" prop="auditItemDsc" align="center" width="100px"></el-table-column>
              <el-table-column label="细分审计事项" prop="auditItemDsc" align="center" width="150px"> </el-table-column>
              <el-table-column label="审计事项摘要" prop="auditorMatterDsc" align="center" width="200px"></el-table-column>
              <el-table-column label="附件名称" prop="docNm" align="center" width="100px"></el-table-column>
              <el-table-column label="编制日期" prop="createDt" align="center" width="200px"></el-table-column>
            <el-table-column label="编制人" prop="rcrdCrtpsnNm" align="center" width="100px"></el-table-column>
              <el-table-column label="状态" prop="lcsCd" align="center" width="100px">
                  <template slot-scope="scope">
                      <span v-if="scope.row.lcsCd === '0'">编制中</span>
                      <span v-else>废弃</span>
                  </template>
              </el-table-column>
              <el-table-column label="已关联的底稿" prop="lcsCd" align="center" width="200px"></el-table-column>

          </el-table>
        </el-row>
        <el-pagination style="margin-top: 10px;" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNum" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="40">
        </el-pagination>
      </div>
    </div>
  </div>
</div>
</template>

<script>
  import evidenceservice from '@/api/auditoperationApi/evidenceservice'
  import axios from 'axios'
export default {
  components: {},
  filters: {
        statusTypeFilter (status) {
            const statusMap = {
                0: 'success',
                1: 'danger'
            }
            return statusMap[status]
        },
        statusFilter (lcsCd) {
            return lcsCd === 0 ? '编制中' : '废弃'
        },
        sexFilter (type) {
            const sexMap = {
                0: '男',
                1: '女'
            }
            return sexMap[type]
        }
    },
  data() {
    return {
      sss: '',
      title: '取证单列表',
      pageNum: 1,
      pageSize: 10,
      data: [{
        b: '测试数据'
      }],
      sels: [],
      model: {
        event: ''
      },
      lcsCdOptions: [{
        value: '1',
        label: '废弃'
      }, {
        value: '0',
        label: '编制中'
      }],
      options: [{
        value: '1',
        label: '事项1'
      }, {
        value: '2',
        label: '事项2'
      }, {
        value: '3',
        label: '事项3'
      }],
      datalist:[],
      flag: false,
      form: {
        auditEvdblNm: '', // 审计取证单名称
        auditItemDsc: '', // 审计事项
        rcrdCrtpsnNm: '', // 编制人
        createDt: '',
        auditorMatterDsc: '',
        lcsCd: '',
        docNm: ''
      },
      newDraftForm: {
        show: false,
        title: '新建底稿'
      }
    }
  },
  computed: {

  },
  mounted() {
     this.getData()
  },
  methods: {
    handleSizeChange(val) {
     this.pageSize = val ;
     this.getData()
    },
    handleCurrentChange(val) {
      this.pageNum = val ;
      this.getData()
    },
    selsChange(sels) {
      this.sels = sels
    },
    reset(){
      this.form = {}
      this.getData ()
    },
    findByParam(){
      let params = this.form
      if(params.createDt){
          params.beforeDate = evidenceservice.formatDate(params.createDt[0],'yyyy-MM-dd hh:mm')
          params.afterDate = evidenceservice.formatDate(params.createDt[1],'yyyy-MM-dd hh:mm')
          params.createDt = ''
      }
      axios.post(evidenceservice.baseUrl +'/evidenceAuditEvdBl/findAuditEvdBlList', params)
              .then(response => {
                //resolve(response);
                this.datalist = response.data.obj;
                //alert(response.data)
              }, err => {
                //reject(err);
              })
              .catch((error) => {
                //reject(error)
              })
    },
    // 保存
    save() {
      this.newDraftForm.show = false
    },

    getData () {
      let params = {}
      let pageNum = this.pageNum
      let pageSize = this.pageSize
        let data = {"pageNum":this.pageNum,"pageSize":this.pageSize}
      axios.post(evidenceservice.baseUrl +'/evidenceAuditEvdBl/findAuditEvdBlList',params)
              .then(response => {
                //resolve(response);
                this.datalist = response.data.obj;
                //alert(response.data)
              }, err => {
                //reject(err);
              })
              .catch((error) => {
                //reject(error)
              })
    },

    deleteById(data){
      let ids= this.sels.map(item => item.auditEvdblId).join()
      if(ids.length > 0){
        this.$confirm('确定废弃该记录?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          axios.post(evidenceservice.baseUrl +'/evidenceAuditEvdBl/updateStatus', {ids: ids})
                  .then(response => {
                    this.$message({
                      type: 'success',
                      message: response.data.obj
                    });
                    this.getData();
                  }, err => {
                  })
                  .catch((error) => {
                  })
        }).catch(action => {
        });
      }else{
        this.$message({
          type: 'info',
          message: '请选择记录'
        });
      }

    },

    //修改取证单
    updateById(auditEvdblId){
      this.$router.push({
            path: '/auditOperationPage/auditevidencedocketadd',query:{auditEvdblId:auditEvdblId}
       })
      /*let auditEvdblId= this.sels.map(item => item.auditEvdblId).join()
      if(this.sels.length == 0){
        this.$message.warning('请勾选一行数据')
      }else if(this.sels.length == 1){
        this.$router.push({
          path: '/auditOperationPage/auditevidencedocketadd',query:{auditEvdblId:auditEvdblId}
        })
      }else{
        this.$message.warning('修改时只能勾选一行')
      }*/
    },

    // 新建取证单
    flushCom() {
      // this.newDraftForm.show = true
      this.$router.push({
        path: '/auditOperationPage/auditevidencedocketadd'
      })
    }
  }
}
</script>

<style lang="less" scoped>
.content-cotainer {
  padding: 0 20px 20px 20px;
  height: 100%;
}
</style>
